package com.gxa.modules.pc.fee.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxa.common.utils.PageUtils;
import com.gxa.modules.model.dto.RefundHistoryDto;
import com.gxa.modules.model.dto.RefundSearchDto;
import com.gxa.modules.model.entity.fee.RefundHistory;
import com.gxa.modules.pc.fee.mapper.RefundHistoryMapper;
import com.gxa.modules.pc.fee.service.RefundHistoryService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 退款记录表 服务实现类
 * </p>
 *
 * @author gxa
 * @since 2022-11-12 05:31:54
 */
@Service
@Slf4j
public class RefundHistoryServiceImpl extends ServiceImpl<RefundHistoryMapper, RefundHistory> implements RefundHistoryService {
    @Autowired
    private RefundHistoryMapper refundHistoryMapper;


    /**
     *带条件的分页查询
     * @param refundSearchDto
     * @return
     */
    @Override
    public PageUtils queryByRefundSearchDto(RefundSearchDto refundSearchDto) {
        Integer pageSize = refundSearchDto.getPageSize();
        Integer pageNum1 = refundSearchDto.getPageNum();

        Integer pageNum2 = (pageNum1-1)*pageSize;
        log.info("---------{}--", pageNum2);
        refundSearchDto.setPageNum(pageNum2);

        List<RefundHistoryDto> list = refundHistoryMapper.queryByRefundSearchDto(refundSearchDto);
        Integer userCount = refundHistoryMapper.findUserCount(refundSearchDto);
        PageUtils pager = new PageUtils(list, userCount, pageSize, pageNum1);

        return pager;
    }

    @Override
    public List<RefundHistoryDto> queryList() {
        List<RefundHistoryDto> refundHistoryDtoList = this.refundHistoryMapper.queryList();
        return refundHistoryDtoList;
    }

    @Override
    public RefundHistoryDto queryById(Integer id) {
        RefundHistoryDto refundHistoryDto = this.refundHistoryMapper.queryById(id);
        return refundHistoryDto;
    }
}
